#include <game/Timer.h>

ARELLO_GAME_NAMESPACE_DECL_START

Timer::Timer() : time(0.0f)
	, lifeTime(0.0f)
	, _paused(true)
	, _release(false)
	, _finished(false)
{}
Timer::~Timer()
{}

void Timer::life_cycle(double delta_time)
{
	lifeTime = lifeTime + delta_time;
	//if(!_paused && time > this->lifeTime)
		

	if(lifeTime > time)
	{
		_finished = true;
		_paused = true;
	}

	if(_release)
		mark_as_dead();
}

void Timer::setTime(float _time)
{
	this->time = _time; 
	lifeTime = 0.0f; 
	_paused = true;
}

float Timer::getTime()
{ 
	return this->time; 
}

float Timer::getLifeTime() 
{
	return this->lifeTime; 
}

void Timer::pause()
{ 
	_paused = true; 
}

void Timer::resume() 
{ 
	_paused  = false; 
}
	
bool Timer::is_paused() 
{
	return this->_paused; 
}

void Timer::release() 
{ 
	this->_release = true; 
}

void Timer::restart()
{
	_paused  = false;
	lifeTime = 0.0f; 
}

void Timer::start()
{
	_paused = false;
}

bool Timer::is_finished()
{
	return this->_finished;
}

ARELLO_GAME_NAMESPACE_DECL_END